const app = getApp()
const connector = require('../../../utils/connector.js')
  //  status:1：审核中 2：审核失败 3：审核成功
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bar_Height: wx.getSystemInfoSync().statusBarHeight + 45,
    /**
     * 审核状态
     * subjects：科目
     * condition：状态 1=>成功 2=>审核中 3=>失败
     * content：备注
     */
    array:[
      { id: '1', subjects: "科目一", condition:"1",time:"2019-12-22",content:""},
      { id: '2', subjects: "科目二", condition: "2", time: "2019-12-22", content: "" },
      { id: '3', subjects: "科目三", condition: "3", time: "2019-12-22", content: "科目二未上传" }
    ],
    gif:"true",//加载动画
  },
  //立即进入
  optionBotBtn(e){
    wx.navigateTo({
      url: '/pages/vip/newVip/newVip',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    userVipList(this)
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
  /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {
    var that = this
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新

  },

})
//理赔进度查询
function userVipList(that){
  connector.getFunc(connector.connector().userVipList, "", "get", app.tokens, function (res) {
    if (res.statusCode == 200) {
      let arr = res.data.result
      // let arr = Array.from(str)
      for(let i=0;i<arr.length;i++){
        let subjectStr = ''
        for(let j=0;j<arr[i].subject.length;j++){
          if(arr[i].subject[j] == 1){
            subjectStr = subjectStr + "科目一 "
          } 
          if(arr[i].subject[j] == 2){
            subjectStr = subjectStr + "科目二 "
          } 
          if(arr[i].subject[j] == 3){
            subjectStr = subjectStr + "科目三 "
          } 
        }
        arr[i].subjectStr = subjectStr
      }
      that.setData({
        array:res.data.result,
        gif:"false",
      })
    } else {
      wx.showToast({
        title: res.statusCode + ":" + res.errMsg,
        icon: 'none',
        duration: 1000
      })
    }
  }, function (res) {
    wx.showToast({
      title: "内部错误",
      icon: 'none',
      duration: 1000
    })
  })
}